home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / newmarch.zip / INFO.C < prev    next >
C/C++ Source or Header  |  1992-09-08  |  2KB  |  87 lines

  1. /* Author:   $Author: jan $
  2.  * File:     $Source: /usr/usrs/jan/desktop/X_Book.boo/programs/RCS/info.c,v $
  3.  * Date:     $Date: 1992/09/09 00:10:03 $
  4.  * Revision: $Revision: 1.1 $
  5.  */
  6.  
  7. #include "copyright.h"
  8.  
  9. /* 
  10. ** File: info.c
  11. ** Purpose: give general information about the server
  12. */
  13.  
  14. /*    
  15. ** Needed for NULL pointer, as well as
  16. ** any IO to an xterm window    
  17. */    
  18. #include <stdio.h>    
  19.     
  20. /*    
  21. ** General X include files    
  22. */    
  23. #include <X11/Xlib.h>    
  24. #include <X11/Xutil.h>    
  25.     
  26. /*    
  27. ** Global variables
  28. */    
  29. Display    *display;    /* the display device */    
  30. int        screen;        /* the screen on the display */
  31.     
  32. /*    
  33. ** Connect to the server and get the display
  34. ** device and the screen number
  35. */    
  36. void
  37. initX ()    
  38. {    
  39.     /* set the display name from
  40.        the environment vbl DISPLAY */    
  41.     display = XOpenDisplay (NULL);    
  42.     if (display == NULL)    
  43.     {    fprintf (stderr,
  44.                 "Unable to open display %s\n",    
  45.                 XDisplayName (NULL));    
  46.         exit (1);    
  47.     } 
  48.     screen = DefaultScreen (display);    
  49. }    
  50.     
  51. /*    
  52. ** Give general info about the server
  53. ** characteristics    
  54. */    
  55. void
  56. report_info ()    
  57. {    
  58.     printf ("There are %d color planes\n", 
  59.             DefaultDepth (display, screen));
  60.     printf ("The display width in pixels is %d\n",
  61.             DisplayWidth (display, screen));    
  62.     printf ("The display depth in pixels is %d\n",
  63.             DisplayHeight (display, screen));    
  64.     printf ("The display name is %s\n",    
  65.             XDisplayName (display));    
  66. }  
  67. /*    
  68. ** Terminate the program gracefully    
  69. */    
  70. void
  71. quitX ()    
  72. {    
  73.     XCloseDisplay (display);    
  74.     exit (0);    
  75. }    
  76.     
  77. int
  78. main (argc, argv)    
  79.     int argc;    
  80.     char **argv;    
  81. {    
  82.     initX ();    
  83.     report_info ();    
  84.     quitX ();
  85.  
  86. }
  87.